function res = viewScopeSignal(obj, device, ch1, ch2, varargin)
%VIEWSCOPESIGNAL Summary of this function goes here
%   Detailed explanation goes here
    p=inputParser; p.KeepUnmatched = true;
    p.addRequired('device', @(x) ismember(x, obj.deviceSerials));
    p.addRequired('ch1',    @ziScopeInput.test);
    p.addRequired('ch2',    @(x) ziScopeInput.test(x) || isempty(x) );

    p.addParameter('trig',  [], @(x) ziScopeTrigInput.test(x) || isempty(x));
    p.addParameter('name', 'SCOPE', @ischar);
    p.addParameter('domain', 'time', @(x) ismember(lower(x), {'time', 'frequency'}));
    p.addParameter('shot_number', 1, @(x) x>0);
    p.addParameter('plot_window', 1, @(x) ismember(x, [1 2]));
    p.addParameter('rate', ziEnumScopeSamplingRate.Rate14_6kHz, @ziEnumScopeSamplingRate.test);
    p.addParameter('duration', 0.1, @(x) x>0);
    p.addParameter('average', 1,    @(x) x>0);
    p.addParameter('slope', ziEnumTrigEdgeSlope.Positive, @ziEnumTrigEdgeSlope.test);
    p.addParameter('level', 0.0, @isnumeric);
    p.addParameter('isSegment', false, @islogical);
    p.addParameter('isCh1BWlimit', true, @islogical);
    p.addParameter('isCh2BWlimit', true, @islogical);
    
    p.parse(device, ch1 ,ch2, varargin{:});
    
    %%
    scp = obj.scopeModule(p.Results.name);    
    scp.initialize();
    scp.setDevice(p.Results.device);
    scp.setSamplingRate(p.Results.rate);
    scp.setDuration(p.Results.duration);
    scp.setMovingAverage(p.Results.average);

    if isempty(p.Results.ch2)
        scp.setInput(p.Results.ch1).enableChannel(ziEnumTwoBitChoice.ONE);
    else
        scp.setInput(p.Results.ch1, p.Results.ch2).enableChannel(ziEnumTwoBitChoice.BOTH);
    end
    
    if isempty(p.Results.trig)
        scp.disableTrigger();
    else
        scp.setTrigger(p.Results.trig, 'slope', p.Results.slope, 'level', p.Results.level);
        scp.enableTrigger();
    end

    if p.Results.isSegment
        scp.enableSegment();
    else
        scp.disableSegment();
    end
    
    if p.Results.isCh1BWlimit
        scp.enableCh1BWLimit();
    else
        scp.disableCh1BWLimit();
    end
    
    if p.Results.isCh2BWlimit
        scp.enableCh2BWLimit();
    else
        scp.enableCh2BWLimit();
    end

    scp.setMode(lower(p.Results.domain));
    res = scp.run('shot_number', p.Results.shot_number, 'plot_window', p.Results.plot_window);
end

